package cn.fay.chapter11;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class Demo1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		List list=new ArrayList(Arrays.asList(1,2,3,4,5,6,7,8,9));
		System.out.println(list);
		List sub=list.subList(1, 4);
		System.out.println(sub);
		Random random=new Random(47);
		Collections.shuffle(sub,random);
		System.out.println(sub);
		System.out.println(list);
		List copy=new ArrayList(list);
		System.out.println(copy);
		copy.removeAll(sub);
		System.out.println(copy);
		copy.retainAll(sub);
		System.out.println(copy);
		list.addAll(3, sub);
		System.out.println(list);
		
	}

}
